<template>
	<view>
		<u-radio-group :disabled="config.disabled" v-model="obj.type" @change="onRadioChange" width="50%">
			<u-radio name="1">中信码</u-radio>
			<u-radio name="2">机构信用码</u-radio>
		</u-radio-group>
		<u-input v-if="obj.type" :disabled="config.disabled" type="text" @input="onInputChange" v-model="obj.code"
			:placeholder="`请填写${obj.type*1===1?'中信码':'机构信用码'}`" />
	</view>
</template>

<script>
	export default {
		props: {
			value: {
				type: Object,
				default: () => {}
			},
			config: {
				type: Object,
				default: () => {}
			},
		},
		model: {
			prop: "value",
			event: "change"
		},
		computed: {
			obj: {
				get() {
					return this.value;
				},
				set(val) {
					this.$emit('change', val);
				}
			}
		},
		methods: {
			onRadioChange(item) {
				this.obj = {
					type: item,
					code: ''
				}
			},
			onInputChange(item) {
				this.obj = {
					...this.obj,
					code: item
				}
			}
		}
	}
</script>